﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yugi.Script;

namespace Yugi.Client.Card
{
    [Serializable]
    public class YTrapCard : YBaseCard
    {
        public TrapType Type
        {
            get;
            set;
        }
        public String Script { get; set; }

        /// <summary>
        /// Dieu kien de kich hoat Trap Card
        /// </summary>
        public String Check_Condition { get; set; }

        public bool CanActive(IDictionary<string, object> pass_argument)
        {
            PythonEngine engine = PythonEngine.GetInsitance();
            if (Check_Condition == "") return false;
            if (engine.addSource(Check_Condition))
            {
                engine.Excute(pass_argument);
                
            }
            return (bool)engine.GetVariable("Result");
        }

        public void Active(IDictionary<string, object> pass_argument)
        {
            PythonEngine engine = PythonEngine.GetInsitance();
            if (Script == "") return;
            if (engine.addSource(Script))
            {
                engine.Excute(pass_argument);
            }
        }
     
    }
}
